;;
;; Defines episode categorization and query.
;;
;; @author  : Hongbing Kou
;; @version : $Id$

;; 
;; Episode classification
;; 
(provide Episode)

(deftemplate episode
    (slot category)
    (slot type)
    (slot explanation (default ""))
)

;
; Query episode classification and its explanation
(defquery episode-classification-query
  (episode (category ?cat) (type ?tp) (explanation ?exp))
)

;;
;; Implements unit-test function to test the results.
;;
(deffunction test-classifier (?name ?type)
    (bind ?result (run-query* episode-classification-query))
    (if (not (?result next)) then 
     	(printout t "????? Episode cannot be classified" crlf)
        (return FALSE)
     )

    (bind ?rname (?result getString cat))
    (bind ?rtype (?result getString tp))
    (bind ?rexp (?result getString exp))
    (if (not (eq ?name ?rname)) then 
        (printout t "????? Expected category name " ?name " but was " ?rname crlf)
        (return FALSE)
     )
        
    (if (not (eq ?type ?rtype)) then 
        (printout t "????? Expected category type " ?type " but was " ?rtype crlf)
        (return FALSE)
            
     )
    
    (printout t "***** Episode " ?name " type " ?type " test passed" crlf)
    (return ?rexp)
)